package com.grass.p019lv.novel.activity;

import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.core.widget.NestedScrollView;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.APPLink;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.AdInfoBean;
import com.androidx.p013lv.base.bean.NovelHistory;
import com.androidx.p013lv.base.bean.UserInfo;
import com.androidx.p013lv.base.bean.event.VoiceProgressEvent;
import com.androidx.p013lv.base.bean.novel.Chapters;
import com.androidx.p013lv.base.bean.novel.FictionList;
import com.androidx.p013lv.base.bean.novel.NovelChapterBean;
import com.androidx.p013lv.base.bean.novel.NovelDetailBean;
import com.androidx.p013lv.base.bean.novel.NovelGuessLikeBean;
import com.androidx.p013lv.base.dialog.BuyVipDialog;
import com.androidx.p013lv.base.event.VoicePlayLoadingEvent;
import com.androidx.p013lv.base.glide.GlideUtils;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.JsonParams;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.service.AdClickService;
import com.androidx.p013lv.base.utils.AdUtils;
import com.androidx.p013lv.base.utils.NovelHistoryUtils;
import com.androidx.p013lv.base.utils.SpUtils;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.grass.p019lv.App;
import com.grass.p019lv.databinding.ActivityVoiceNewBinding;
import com.grass.p019lv.event.EventBusEvent;
import com.grass.p019lv.event.EventBusUtils;
import com.grass.p019lv.event.NovelCommentNumEvent;
import com.grass.p019lv.event.VoiceErrorEvent;
import com.grass.p019lv.event.VoicePlayStatusEvent;
import com.grass.p019lv.novel.adapter.NovelMenuAdapter;
import com.grass.p019lv.novel.adapter.VoiceNovelGuessLikeAdapter;
import com.grass.p019lv.novel.fragment.NovelCommentFragment;
import com.grass.p019lv.novel.viewmodel.NovelModel;
import com.grass.p019lv.service.MediaService;
import com.grass.p019lv.view.CustomSeekBar;
import com.gyf.immersionbar.ImmersionBar;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import p023io.reactivex.android.schedulers.AndroidSchedulers;
import p023io.reactivex.disposables.CompositeDisposable;
import p023io.reactivex.functions.Action;
import p023io.reactivex.schedulers.Schedulers;

/* renamed from: com.grass.lv.novel.activity.VoiceNovelActivityNew */
public class VoiceNovelActivityNew extends BaseActivity<ActivityVoiceNewBinding> implements NovelCommentFragment.NovelCommentInterface {
    private Animation animationIn;
    private Animation animationOut;
    private APPLink appLink;
    private List<Integer> chapterIdList = new ArrayList();
    private List<Chapters> chapters;
    private int commentNum;
    int currentPosition;
    private LinearLayout ll_root;
    int maxPosition;
    private int novelChapterId;
    private NovelCommentFragment novelCommentFragment;
    private NovelDetailBean novelDetailBean;
    private int novelId;
    private NovelMenuAdapter novelMenuAdapter;
    private NovelModel novelModel;
    private PopupWindow popMenu;
    private View pop_view;
    private RotateAnimation rotate;
    private TextView tv_menu_title;
    private VoiceNovelGuessLikeAdapter voiceNovelGuessLikeAdapter;

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return R.layout.activity_voice_new;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityVoiceNewBinding) this.binding).toolBar).init();
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        EventBus.getDefault().register(this);
        this.novelId = getIntent().getIntExtra(Key.NOVEL_ID, 0);
        ViewGroup.LayoutParams layoutParams = ((ActivityVoiceNewBinding) this.binding).ivCover.getLayoutParams();
        layoutParams.height = UiUtils.getWindowWidth() - UiUtils.dp2px(80);
        ((ActivityVoiceNewBinding) this.binding).ivCover.setLayoutParams(layoutParams);
        ((ActivityVoiceNewBinding) this.binding).setClick(new OnClick());
        this.novelModel = (NovelModel) new ViewModelProvider(this).get(NovelModel.class);
        NovelCommentFragment newInstance = NovelCommentFragment.newInstance();
        this.novelCommentFragment = newInstance;
        newInstance.setCommentInterface(this);
        ((ActivityVoiceNewBinding) this.binding).scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C31061 */

            @Override // androidx.core.widget.NestedScrollView.OnScrollChangeListener
            public void onScrollChange(NestedScrollView nestedScrollView, int i, int i2, int i3, int i4) {
                if (i2 == 0) {
                    ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).llTool.setVisibility(8);
                } else {
                    ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).llTool.setVisibility(0);
                }
            }
        });
        initSeekBar();
        this.voiceNovelGuessLikeAdapter = new VoiceNovelGuessLikeAdapter();
        ((ActivityVoiceNewBinding) this.binding).recycler.setLayoutManager(new LinearLayoutManager(this, 0, false));
        ((ActivityVoiceNewBinding) this.binding).recycler.setAdapter(this.voiceNovelGuessLikeAdapter);
        ((ActivityVoiceNewBinding) this.binding).recycler.setFocusable(false);
        ((ActivityVoiceNewBinding) this.binding).recycler.setNestedScrollingEnabled(false);
        this.voiceNovelGuessLikeAdapter.setOnItemClickListener(new OnItemClickListener() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C31142 */

            @Override // com.chad.library.adapter.base.listener.OnItemClickListener
            public void onItemClick(BaseQuickAdapter<?, ?> baseQuickAdapter, View view, int i) {
                if (SpUtils.getInstance().getUserInfo().getFreeWatches() != -1) {
                    new BuyVipDialog(VoiceNovelActivityNew.this).show();
                    return;
                }
                VoiceNovelActivityNew.this.novelModel.getNovelInfo(((FictionList) VoiceNovelActivityNew.this.voiceNovelGuessLikeAdapter.getItem(i)).getFictionId());
                ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).scrollView.scrollTo(0, 0);
            }
        });
        ((ActivityVoiceNewBinding) this.binding).ivPlaying.setImageResource(R.drawable.ic_voice_playing1);
        this.rotate = new RotateAnimation(0.0f, 360.0f, 1, 0.5f, 1, 0.5f);
        this.rotate.setInterpolator(new LinearInterpolator());
        this.rotate.setDuration(1000);
        this.rotate.setRepeatCount(-1);
        this.rotate.setFillAfter(false);
        this.rotate.setStartOffset(0);
        initPopUpView();
        setAd();
    }

    /* access modifiers changed from: package-private */
    public void setAd() {
        final AdInfoBean voiceNovelAd = AdUtils.getInstance().getVoiceNovelAd();
        if (voiceNovelAd == null) {
            ((ActivityVoiceNewBinding) this.binding).rlAd.setVisibility(8);
            ((ActivityVoiceNewBinding) this.binding).ivAd.setVisibility(8);
            ((ActivityVoiceNewBinding) this.binding).tvAd.setVisibility(8);
            return;
        }
        ViewGroup.LayoutParams layoutParams = ((ActivityVoiceNewBinding) this.binding).rlAd.getLayoutParams();
        layoutParams.height = ((UiUtils.getWindowWidth() - UiUtils.dp2px(20)) * 120) / 400;
        ((ActivityVoiceNewBinding) this.binding).rlAd.setLayoutParams(layoutParams);
        ((ActivityVoiceNewBinding) this.binding).rlAd.setVisibility(0);
        ((ActivityVoiceNewBinding) this.binding).ivAd.setVisibility(0);
        ((ActivityVoiceNewBinding) this.binding).tvAd.setVisibility(0);
        GlideUtils.loadCropRadius(SpUtils.getInstance().getString("domain") + voiceNovelAd.getAdImage(), 4, ((ActivityVoiceNewBinding) this.binding).ivAd);
        ((ActivityVoiceNewBinding) this.binding).ivAd.setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.View$OnClickListenerC31153 */

            public void onClick(View view) {
                if (voiceNovelAd.getJumpType() == 2) {
                    try {
                        Intent intent = new Intent();
                        intent.setAction("android.intent.action.VIEW");
                        intent.setData(Uri.parse(voiceNovelAd.getAdJump()));
                        VoiceNovelActivityNew.this.startActivity(intent);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    if (VoiceNovelActivityNew.this.appLink == null) {
                        VoiceNovelActivityNew voiceNovelActivityNew = VoiceNovelActivityNew.this;
                        voiceNovelActivityNew.appLink = new APPLink(voiceNovelActivityNew.getActivity());
                    }
                    VoiceNovelActivityNew.this.appLink.urlLink(voiceNovelAd.getAdJump());
                }
                Intent intent2 = new Intent(VoiceNovelActivityNew.this.getActivity(), AdClickService.class);
                intent2.putExtra("adId", voiceNovelAd.getAdId());
                VoiceNovelActivityNew.this.getActivity().startService(intent2);
            }
        });
    }

    private void initSeekBar() {
        ((ActivityVoiceNewBinding) this.binding).seekbar.setProgressBarHeight(2.0f);
        ((ActivityVoiceNewBinding) this.binding).seekbar.setCacheProgressBarHeight(1.5f);
        ((ActivityVoiceNewBinding) this.binding).seekbar.setProgressBarColor(17170432);
        ((ActivityVoiceNewBinding) this.binding).seekbar.setCacheProgressBarColor(17170443);
        ((ActivityVoiceNewBinding) this.binding).seekbar.setTextBgColor(17170443);
        ((ActivityVoiceNewBinding) this.binding).seekbar.setTextColor(17170444);
        ((ActivityVoiceNewBinding) this.binding).seekbar.setTextSize(10);
        ((ActivityVoiceNewBinding) this.binding).seekbar.setProgressListener(new CustomSeekBar.IProgressListener() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C31164 */

            @Override // com.grass.p019lv.view.CustomSeekBar.IProgressListener
            public void progress(int i) {
                EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_SEEK, Integer.valueOf(i * 1000)));
            }
        });
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initData() {
        super.initData();
        this.novelModel.getNovelInfoData().observe(this, new Observer<BaseRes<NovelDetailBean>>() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C31175 */

            public void onChanged(BaseRes<NovelDetailBean> baseRes) {
                if (200 == baseRes.getCode() && baseRes.getData() != null) {
                    VoiceNovelActivityNew.this.novelDetailBean = baseRes.getData();
                    VoiceNovelActivityNew voiceNovelActivityNew = VoiceNovelActivityNew.this;
                    voiceNovelActivityNew.insertHistory(voiceNovelActivityNew.novelDetailBean);
                    List<NovelDetailBean.TagList> tagList = baseRes.getData().getTagList();
                    if (tagList != null && tagList.size() > 0) {
                        VoiceNovelActivityNew.this.setNovelTag(tagList);
                    }
                    VoiceNovelActivityNew.this.chapters = baseRes.getData().getChapters();
                    if (VoiceNovelActivityNew.this.chapters != null && VoiceNovelActivityNew.this.chapters.size() > 0) {
                        VoiceNovelActivityNew.this.novelMenuAdapter.setData(VoiceNovelActivityNew.this.chapters);
                        VoiceNovelActivityNew.this.chapterIdList.clear();
                        for (int i = 0; i < VoiceNovelActivityNew.this.chapters.size(); i++) {
                            VoiceNovelActivityNew.this.chapterIdList.add(Integer.valueOf(((Chapters) VoiceNovelActivityNew.this.chapters.get(i)).getChapterId()));
                        }
                    }
                    if (!TextUtils.isEmpty(baseRes.getData().getCoverImg())) {
                        App.floatingCoverImg = SpUtils.getInstance().getString("domain") + baseRes.getData().getCoverImg();
                        GlideUtils.loadCropRadiusWh2(App.floatingCoverImg, 4, ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCover, Constance.BIG_PIC);
                    } else {
                        App.floatingCoverImg = "";
                        GlideUtils.loadCropRadiusDefault(4, ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCover);
                    }
                    VoiceNovelActivityNew voiceNovelActivityNew2 = VoiceNovelActivityNew.this;
                    voiceNovelActivityNew2.novelChapterId = ((Chapters) voiceNovelActivityNew2.chapters.get(0)).getChapterId();
                    if (baseRes.getData().getFictionId() != App.novelId) {
                        VoiceNovelActivityNew voiceNovelActivityNew3 = VoiceNovelActivityNew.this;
                        voiceNovelActivityNew3.initAudioService(voiceNovelActivityNew3.chapterIdList, baseRes.getData().getFictionId());
                    } else {
                        VoiceNovelActivityNew.this.novelChapterId = App.chapterId;
                        VoiceNovelActivityNew.this.novelMenuAdapter.setChapterId(App.chapterId);
                        VoiceNovelActivityNew.this.getNovelChpaterInfo(App.novelId, App.chapterId);
                    }
                    if (VoiceNovelActivityNew.this.chapters != null && VoiceNovelActivityNew.this.chapters.size() > 0) {
                        for (int i2 = 0; i2 < VoiceNovelActivityNew.this.chapters.size(); i2++) {
                            if (VoiceNovelActivityNew.this.novelChapterId == ((Chapters) VoiceNovelActivityNew.this.chapters.get(i2)).getChapterId()) {
                                TextView textView = ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).tvTitle;
                                textView.setText(((Chapters) VoiceNovelActivityNew.this.chapters.get(i2)).getChapterTitle() + "");
                            }
                        }
                    }
                    TextView textView2 = VoiceNovelActivityNew.this.tv_menu_title;
                    textView2.setText(baseRes.getData().getFictionTitle() + "");
                    TextView textView3 = ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).tvToolTitle;
                    textView3.setText(baseRes.getData().getFictionTitle() + "");
                    if (VoiceNovelActivityNew.this.novelDetailBean.getIsLike()) {
                        ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCollect.setImageResource(0);
                        ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCollect.setImageResource(R.drawable.ic_novel_collect_ok);
                        return;
                    }
                    ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCollect.setImageResource(0);
                    ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCollect.setImageResource(R.drawable.ic_novel_collect_no);
                }
            }
        });
        this.novelModel.getNovelChapterInfoData().observe(this, new Observer<BaseRes<NovelChapterBean>>() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C31186 */

            public void onChanged(BaseRes<NovelChapterBean> baseRes) {
                if (200 == baseRes.getCode()) {
                    TextView textView = ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).tvDonate;
                    textView.setText(baseRes.getData().getIncome() + "");
                    VoiceNovelActivityNew.this.commentNum = baseRes.getData().getCommentNum();
                    TextView textView2 = ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).tvComment;
                    textView2.setText(VoiceNovelActivityNew.this.commentNum + "");
                }
            }
        });
        this.novelModel.getNovelInfo(this.novelId);
        getGuessLike(this.novelId);
    }

    public void insertHistory(NovelDetailBean novelDetailBean2) {
        String coverImg = (novelDetailBean2.getCoverImg() == null || TextUtils.isEmpty(novelDetailBean2.getCoverImg())) ? "" : novelDetailBean2.getCoverImg();
        List<NovelDetailBean.TagList> tagList = novelDetailBean2.getTagList();
        ArrayList arrayList = new ArrayList();
        if (tagList != null && tagList.size() > 0) {
            for (int i = 0; i < tagList.size(); i++) {
                arrayList.add(tagList.get(i).getTitle());
            }
        }
        NovelHistory novelHistory = new NovelHistory(coverImg, novelDetailBean2.getFakeLikes(), novelDetailBean2.getFakeWatchTimes(), novelDetailBean2.getFictionId(), novelDetailBean2.getFictionSpace(), novelDetailBean2.getFictionTitle(), novelDetailBean2.getFictionType(), novelDetailBean2.getInfo(), arrayList);
        final CompositeDisposable compositeDisposable = new CompositeDisposable();
        compositeDisposable.add(NovelHistoryUtils.getInstance().insert(novelHistory).subscribeOn(Schedulers.m1118io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C31197 */

            @Override // p023io.reactivex.functions.Action
            public void run() throws Exception {
                Log.e("---->", "add----ok");
                compositeDisposable.clear();
            }
        }));
    }

    /* access modifiers changed from: protected */
    @Override // androidx.fragment.app.FragmentActivity
    public void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        int intExtra = intent.getIntExtra(Key.NOVEL_ID, 0);
        this.novelId = intExtra;
        this.novelModel.getNovelInfo(intExtra);
        getGuessLike(this.novelId);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void initAudioService(List<Integer> list, int i) {
        Intent intent = new Intent(this, MediaService.class);
        intent.putExtra(Constance.service_data, (Serializable) list);
        intent.putExtra(Constance.service_novelId, i);
        if (Build.VERSION.SDK_INT >= 26) {
            startForegroundService(intent);
        } else {
            startService(intent);
        }
    }

    private void initPopUpView() {
        this.animationIn = AnimationUtils.loadAnimation(this, R.anim.pop_window_in);
        this.animationOut = AnimationUtils.loadAnimation(this, R.anim.pop_window_out);
        View inflate = View.inflate(this, R.layout.popup_novel_with_navi, null);
        this.pop_view = inflate;
        this.ll_root = (LinearLayout) inflate.findViewById(R.id.ll_root);
        this.tv_menu_title = (TextView) this.pop_view.findViewById(R.id.tv_menu_title);
        this.animationOut.setAnimationListener(new Animation.AnimationListener() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.animationAnimation$AnimationListenerC31208 */

            public void onAnimationRepeat(Animation animation) {
            }

            public void onAnimationStart(Animation animation) {
            }

            public void onAnimationEnd(Animation animation) {
                VoiceNovelActivityNew.this.popMenu.dismiss();
            }
        });
        this.novelMenuAdapter = new NovelMenuAdapter();
        final RecyclerView recyclerView = (RecyclerView) this.pop_view.findViewById(R.id.recycler);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(this.novelMenuAdapter);
        this.pop_view.findViewById(R.id.btn_v_out).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.View$OnClickListenerC31219 */

            public void onClick(View view) {
                VoiceNovelActivityNew.this.ll_root.startAnimation(VoiceNovelActivityNew.this.animationOut);
            }
        });
        this.pop_view.findViewById(R.id.tv_go_bottom).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.View$OnClickListenerC310710 */

            public void onClick(View view) {
                recyclerView.scrollToPosition(VoiceNovelActivityNew.this.novelMenuAdapter.getItemCount() - 1);
            }
        });
        this.novelMenuAdapter.setItemListener(new ItemClickListener() {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C310811 */

            @Override // com.androidx.p013lv.base.listener.ItemClickListener
            public void onItemClick(View view, int i) {
                VoiceNovelActivityNew.this.ll_root.startAnimation(VoiceNovelActivityNew.this.animationOut);
                Chapters chapters = (Chapters) VoiceNovelActivityNew.this.novelMenuAdapter.getDataInPosition(i);
                VoiceNovelActivityNew.this.novelMenuAdapter.setChapterId(chapters.getChapterId());
                VoiceNovelActivityNew.this.novelChapterId = chapters.getChapterId();
                EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_SELECT, Integer.valueOf(VoiceNovelActivityNew.this.novelChapterId)));
            }
        });
        PopupWindow popupWindow = new PopupWindow(this.pop_view, -1, -1);
        this.popMenu = popupWindow;
        popupWindow.setOutsideTouchable(true);
        this.popMenu.setBackgroundDrawable(new ColorDrawable());
        this.popMenu.setClippingEnabled(false);
    }

    private void getGuessLike(int i) {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().getNovelGuessLike(i), new HttpCallback<BaseRes<NovelGuessLikeBean>>("getGuessLike") {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C310912 */

            public void onLvSuccess(BaseRes<NovelGuessLikeBean> baseRes) {
                if (baseRes.getCode() == 200) {
                    VoiceNovelActivityNew.this.voiceNovelGuessLikeAdapter.setNewInstance(baseRes.getData().getData());
                }
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void setNovelTag(final List<NovelDetailBean.TagList> list) {
        ((ActivityVoiceNewBinding) this.binding).flowType.setAdapter(new TagAdapter<NovelDetailBean.TagList>(list) {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C311013 */

            public View getView(FlowLayout flowLayout, final int i, NovelDetailBean.TagList tagList) {
                RelativeLayout relativeLayout = (RelativeLayout) LayoutInflater.from(flowLayout.getContext()).inflate(R.layout.tag_voice_play, (ViewGroup) flowLayout, false);
                TextView textView = (TextView) relativeLayout.findViewById(R.id.tv_label);
                textView.setText(((NovelDetailBean.TagList) list.get(i)).getTitle());
                textView.setOnClickListener(new View.OnClickListener() {
                    /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C311013.View$OnClickListenerC31111 */

                    public void onClick(View view) {
                        if (!VoiceNovelActivityNew.this.isOnClick()) {
                            Intent intent = new Intent(VoiceNovelActivityNew.this, VoiceNovelLabelActivity.class);
                            intent.putExtra(Key.TITLE, ((NovelDetailBean.TagList) list.get(i)).getTitle());
                            intent.putExtra("tagId", ((NovelDetailBean.TagList) list.get(i)).getTagId());
                            VoiceNovelActivityNew.this.startActivity(intent);
                        }
                    }
                });
                return relativeLayout;
            }
        });
    }

    /* access modifiers changed from: protected */
    @Override // androidx.fragment.app.FragmentActivity
    public void onResume() {
        super.onResume();
        getUserInfo();
    }

    public void getUserInfo() {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().userInfo(), JsonParams.build().commit(), new HttpCallback<BaseRes<UserInfo>>("userInfo") {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C311214 */

            public void onLvSuccess(BaseRes<UserInfo> baseRes) {
                if (baseRes.getCode() == 200) {
                    SpUtils.getInstance().setUserInfo(baseRes.getData());
                }
            }
        });
    }

    @Override // com.grass.p019lv.novel.fragment.NovelCommentFragment.NovelCommentInterface
    public void addCommentNum(int i, int i2) {
        this.commentNum = i2;
        TextView textView = ((ActivityVoiceNewBinding) this.binding).tvComment;
        textView.setText(this.commentNum + "");
    }

    /* renamed from: com.grass.lv.novel.activity.VoiceNovelActivityNew$OnClick */
    public class OnClick {
        public void donateVoice() {
        }

        public OnClick() {
        }

        public void btnBack() {
            VoiceNovelActivityNew.this.finish();
        }

        public void collectVoice() {
            VoiceNovelActivityNew.this.novelModel.collectNovel(VoiceNovelActivityNew.this.novelId, !VoiceNovelActivityNew.this.novelDetailBean.getIsLike());
            VoiceNovelActivityNew.this.novelDetailBean.setIsLike(!VoiceNovelActivityNew.this.novelDetailBean.getIsLike());
            if (VoiceNovelActivityNew.this.novelDetailBean.getIsLike()) {
                ToastUtils.getInstance().showCorrect("收藏成功");
                ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCollect.setImageResource(0);
                ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCollect.setImageResource(R.drawable.ic_novel_collect_ok);
                return;
            }
            ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCollect.setImageResource(0);
            ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).ivCollect.setImageResource(R.drawable.ic_novel_collect_no);
        }

        public void commentVoice() {
            VoiceNovelActivityNew.this.ll_root.startAnimation(VoiceNovelActivityNew.this.animationIn);
            VoiceNovelActivityNew.this.novelCommentFragment.loadNovelComment(0, VoiceNovelActivityNew.this.novelId, VoiceNovelActivityNew.this.novelChapterId, VoiceNovelActivityNew.this.commentNum, 0);
            VoiceNovelActivityNew.this.novelCommentFragment.show(VoiceNovelActivityNew.this.getSupportFragmentManager(), "NovelCommentFragment");
        }

        public void previousPlaySeconds() {
            if (!VoiceNovelActivityNew.this.isOnClick()) {
                if (VoiceNovelActivityNew.this.currentPosition > 15000) {
                    VoiceNovelActivityNew.this.currentPosition -= 15000;
                } else {
                    VoiceNovelActivityNew.this.currentPosition = 0;
                }
                EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_SEEK, Integer.valueOf(VoiceNovelActivityNew.this.currentPosition)));
            }
        }

        public void nextPlaySeconds() {
            if (!VoiceNovelActivityNew.this.isOnClick() && VoiceNovelActivityNew.this.maxPosition - VoiceNovelActivityNew.this.currentPosition >= 15000) {
                EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_SEEK, Integer.valueOf(VoiceNovelActivityNew.this.currentPosition + 15000)));
            }
        }

        public void previousPlay() {
            if (!VoiceNovelActivityNew.this.isOnClick()) {
                EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_NEXT_PREPARE));
            }
        }

        public void nextPlay() {
            if (!VoiceNovelActivityNew.this.isOnClick()) {
                EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_NEXT));
            }
        }

        public void togglePlay() {
            if (!VoiceNovelActivityNew.this.isOnClick()) {
                EventBusUtils.sendEvent(new EventBusEvent(EventBusUtils.EventCode.SERVICE_PLAY_PAUSE));
            }
        }

        public void novelMenu() {
            VoiceNovelActivityNew.this.ll_root.startAnimation(VoiceNovelActivityNew.this.animationIn);
            VoiceNovelActivityNew.this.popMenu.showAtLocation(((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).rootView, 17, 0, 0);
        }
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
        if (((ActivityVoiceNewBinding) this.binding).ivPlayLoading != null) {
            ((ActivityVoiceNewBinding) this.binding).ivPlayLoading.clearAnimation();
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventBus(VoicePlayLoadingEvent voicePlayLoadingEvent) {
        if (((ActivityVoiceNewBinding) this.binding).ivPlayLoading == null) {
            return;
        }
        if (voicePlayLoadingEvent.isLoading()) {
            ((ActivityVoiceNewBinding) this.binding).ivPlayLoading.setVisibility(0);
            ((ActivityVoiceNewBinding) this.binding).ivPlayLoading.startAnimation(this.rotate);
            return;
        }
        ((ActivityVoiceNewBinding) this.binding).ivPlayLoading.setVisibility(4);
        ((ActivityVoiceNewBinding) this.binding).ivPlayLoading.clearAnimation();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onProgressEventBus(VoiceProgressEvent voiceProgressEvent) {
        this.currentPosition = voiceProgressEvent.getProgress();
        this.maxPosition = voiceProgressEvent.getDuration();
        ((ActivityVoiceNewBinding) this.binding).seekbar.setMaxProgress(voiceProgressEvent.getDuration() / 1000);
        ((ActivityVoiceNewBinding) this.binding).seekbar.progress(voiceProgressEvent.getProgress() / 1000);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void commentNumEvent(NovelCommentNumEvent novelCommentNumEvent) {
        this.novelChapterId = novelCommentNumEvent.getChapterId();
        this.commentNum = novelCommentNumEvent.getCommentNum();
        TextView textView = ((ActivityVoiceNewBinding) this.binding).tvComment;
        textView.setText(this.commentNum + "");
        this.novelMenuAdapter.setChapterId(this.novelChapterId);
        List<Chapters> list = this.chapters;
        if (list != null && list.size() > 0) {
            for (int i = 0; i < this.chapters.size(); i++) {
                if (this.novelChapterId == this.chapters.get(i).getChapterId()) {
                    TextView textView2 = ((ActivityVoiceNewBinding) this.binding).tvTitle;
                    textView2.setText(this.chapters.get(i).getChapterTitle() + "");
                }
            }
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void voicePlayStatusEvent(VoicePlayStatusEvent voicePlayStatusEvent) {
        ((ActivityVoiceNewBinding) this.binding).setPlayStatus(!voicePlayStatusEvent.isVoicePlayStatus());
        if (!voicePlayStatusEvent.isVoicePlayStatus()) {
            ((ActivityVoiceNewBinding) this.binding).ivPlaying.setImageResource(0);
            ((ActivityVoiceNewBinding) this.binding).ivPlaying.setImageResource(R.drawable.ic_voice_playing1);
            return;
        }
        ((ActivityVoiceNewBinding) this.binding).ivPlaying.setImageResource(0);
        Glide.with((FragmentActivity) this).load(Integer.valueOf((int) R.drawable.ic_voice_playing_anim)).into(((ActivityVoiceNewBinding) this.binding).ivPlaying);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void Event(VoiceErrorEvent voiceErrorEvent) {
        int errorCode = voiceErrorEvent.getErrorCode();
        if (errorCode == 4) {
            ToastUtils.getInstance().showSigh("播放出错");
        } else if (errorCode == 5) {
            ToastUtils.getInstance().showSigh("没有更多了");
        }
    }

    public void getNovelChpaterInfo(int i, int i2) {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().getNovelChapterInfo(i, i2), new HttpCallback<BaseRes<NovelChapterBean>>("novelChapterInfo") {
            /* class com.grass.p019lv.novel.activity.VoiceNovelActivityNew.C311315 */

            public void onLvSuccess(BaseRes<NovelChapterBean> baseRes) {
                if (200 == baseRes.getCode()) {
                    TextView textView = ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).tvDonate;
                    textView.setText(baseRes.getData().getIncome() + "");
                    VoiceNovelActivityNew.this.commentNum = baseRes.getData().getCommentNum();
                    TextView textView2 = ((ActivityVoiceNewBinding) VoiceNovelActivityNew.this.binding).tvComment;
                    textView2.setText(VoiceNovelActivityNew.this.commentNum + "");
                }
            }
        });
    }
}
